<template>
  <div>
    <JVxeTable 
      keep-source 
      resizable 
      ref="finalAssemblyPlan"
      :loading="finalAssemblyPlanTable.loading"
      :columns="finalAssemblyPlanTable.columns"
      :dataSource="finalAssemblyPlanTable.dataSource" 
      :pagination="pagination"
      @pageChange="pageChange"
      :height="500"
      :rowNumber="true"
    />
  </div>
</template>

<script lang="ts" setup>
  import { ref, reactive, onMounted } from 'vue';
  import { JVxeTable } from '/@/components/jeecg/JVxeTable';
  import { useJvxeMethod } from '/@/hooks/system/useJvxeMethods';
  import { formSchema, finalAssemblyPlanColumns } from '../finalAssemblyPlan.data.ts';
  import { list } from '../finalAssemblyPlan.api.ts';
  const props = defineProps({
    searchParams: {
      type: Object,
      default: {}
    }
  });
  defineExpose({getList});
  const finalAssemblyPlan = ref();
  const finalAssemblyPlanTable = reactive({
    loading: false,
    dataSource: [],
    columns: finalAssemblyPlanColumns
  });
  // 分页器
  const pagination = reactive({
    current: 1,
    pageSize: 10,
    total: 0
  })
  //方法配置
  const [handleChangeTabs, handleSubmit, requestSubTableData, formRef] = useJvxeMethod();
  onMounted(() => {
    getList();
  });
  // 获取列表
  function getList() {
    // 处理表格搜索参数
    let tempSearchParams = {
      createdDateStart: props.searchParams.createdDate ? props.searchParams.createdDate[0] : '',
      createdDateEnd:  props.searchParams.createdDate ? props.searchParams.createdDate[1] : '',
      plannedStartDateStart:  props.searchParams.plannedStartDate ? props.searchParams.plannedStartDate[0] : '',
      plannedStartDateEnd:  props.searchParams.plannedStartDate ? props.searchParams.plannedStartDate[1] : '',
      releasedDateStart:  props.searchParams.releasedDate ? props.searchParams.releasedDate[0] : '',
      releasedDateEnd:  props.searchParams.releasedDate ? props.searchParams.releasedDate[1] : '',
      moNo: props.searchParams.moNo,
      workCenterName: props.searchParams.workCenterName,
      productionOrderStateName: props.searchParams.productionOrderStateName,
      partCode: props.searchParams.partCode
    };
    // 处理分页参数
    let tempParams = {
      pageNo: pagination.current,
      pageSize: pagination.pageSize
    };
    let params = Object.assign(tempSearchParams,tempParams);

    requestSubTableData(list, params, finalAssemblyPlanTable,(res) => {
      if(res.code == 200) {
        pagination.total = res.result.total;
      }
    });
  }
  function pageChange({current,pageSize}) {
    pagination.current = current;
    pagination.pageSize = pageSize;
    getList();
  }
</script>

<style lang="less" scoped>
  /** 时间和数字输入框样式 */
  :deep(.ant-input-number) {
    width: 100%
  }

  :deep(.ant-calendar-picker) {
    width: 100%
  }

</style>
